Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] fix: Clean up sync URL subscription in Discover plugin topNav #9316

Merged
merged 4 commits into from
Feb 12, 2025

Conversation

Maosaic
Copy link
Contributor

@Maosaic Maosaic commented Jan 31, 2025

Description

Properly clean up sync URL subscription in Discover plugin topNav component.

Changes this PR contains:

  1. Create useSyncQueryStateWithUrl hook which automatically cancel sync URL subscription.
  2. Invoke useSyncQueryStateWithUrl from topNav component, so the URL subscription will be properly clean up when user navigate away from Discover page.
  3. Rewrite SavedObjectSaveModal as functional component.

Issues Resolved

fixes #9309

Screenshot

Before

Screen.Recording.2025-01-29.at.2.56.41.PM.mp4

After

Screen.Recording.2025-01-31.at.10.43.38.AM.mp4

Testing the changes

Changelog

  • fix: Clean up sync URL subscription in Discover plugin topNav

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Jan 31, 2025

Codecov Report

Attention: Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 61.71%. Comparing base (ec6d7df) to head (2a0bfad).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
...plication/components/top_nav/get_top_nav_links.tsx 0.00% 3 Missing ⚠️
...lic/application/view_components/canvas/top_nav.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9316   +/-   ##
=======================================
  Coverage   61.70%   61.71%           
=======================================
  Files        3816     3817    +1     
  Lines       91829    91841   +12     
  Branches    14543    14545    +2     
=======================================
+ Hits        56666    56677   +11     
- Misses      31507    31508    +1     
  Partials     3656     3656           
Flag Coverage Δ
Linux_1 28.98% <6.66%> (-0.01%) ⬇️
Linux_2 56.46% <ø> (ø)
Linux_3 39.19% <73.33%> (+0.01%) ⬆️
Linux_4 28.90% <6.66%> (-0.01%) ⬇️
Windows_1 29.00% <6.66%> (-0.01%) ⬇️
Windows_2 56.41% <ø> (ø)
Windows_3 39.19% <73.33%> (+0.01%) ⬆️
Windows_4 28.90% <6.66%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kavilla kavilla added backport 2.x discover for discover reinvent labels Feb 5, 2025
@kavilla
Copy link
Member

kavilla commented Feb 6, 2025

do you mind checking the ci failures? is the ci failing on main?

@Maosaic
Copy link
Contributor Author

Maosaic commented Feb 6, 2025

do you mind checking the ci failures? is the ci failing on main?

I see the same test error in other PR, I don't think that's related to my change

@abbyhu2000
Copy link
Member

@Maosaic one comment but not blocking.

I see we use useSyncQueryStateWithUrl to wrap syncQueryStateWithUrl for discover plugin.

Other plugins also uses syncQueryStateWithUrl
*dashboard

const { stop: stopSyncingQueryServiceStateWithUrl } = syncQueryStateWithUrl(

const { stop } = syncQueryStateWithUrl(query, osdUrlStateStorage);

*visbuilder

const { stop } = syncQueryStateWithUrl(query, osdUrlStateStorage);

*visualization

const { stop } = syncQueryStateWithUrl(query, osdUrlStateStorage);

should we also replace those with useSyncQueryStateWithUrl as well?

@abbyhu2000 abbyhu2000 merged commit 8cc5f84 into opensearch-project:main Feb 12, 2025
69 of 71 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 12, 2025
…Nav (#9316)

* [Discover] fix: Clean up sync URL subscription in Discover plugin topNav

Signed-off-by: Joey Liu <[email protected]>

* Changeset file for PR #9316 created/updated

* Update unit test

Signed-off-by: Joey Liu <[email protected]>

* Revert save modal change

Signed-off-by: Joey Liu <[email protected]>

---------

Signed-off-by: Joey Liu <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 8cc5f84)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@Maosaic
Copy link
Contributor Author

Maosaic commented Feb 13, 2025

@Maosaic one comment but not blocking.

I see we use useSyncQueryStateWithUrl to wrap syncQueryStateWithUrl for discover plugin.

Other plugins also uses syncQueryStateWithUrl *dashboard

const { stop: stopSyncingQueryServiceStateWithUrl } = syncQueryStateWithUrl(

const { stop } = syncQueryStateWithUrl(query, osdUrlStateStorage);

*visbuilder

const { stop } = syncQueryStateWithUrl(query, osdUrlStateStorage);

*visualization

const { stop } = syncQueryStateWithUrl(query, osdUrlStateStorage);

should we also replace those with useSyncQueryStateWithUrl as well?

We can, but not necessary, those are manually calling stop

@Maosaic Maosaic deleted the topnav branch February 13, 2025 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Error restoring state from URL when navigate between Discover and Dashboard
4 participants